package com.itheima.dao;

import org.apache.ibatis.annotations.*;

import com.itheima.domain.Book;

import java.util.List;

/**
 * @author jay
 */
//TODO 添加@Mapper 让Mybatis扫描接口并创建接口的代码对象交给Spring管理
@Mapper
public interface BookDao {
    @Insert("INSERT INTO tbl_book values (null, #{type}, #{name}, #{description})")
    int save(Book book);

    @Update("update tbl_book set type =#{type},name=#{name},description=#{description} where id=#{id}")
    int update(Book book);

    @Delete("delete from tbl_book where id = #{id}")
    int delete(Integer id);

    @Select("select * from tbl_book where id = #{id}")
    Book selectById(Integer id);

    @Select("select * from tbl_book")
    List<Book> selectAll();
}
